{layout name="p/base"}
  <div id="page-wrapper">
    <div class="row">
      <div class="col-lg-12">
        <h1>房车管理 <small>编辑房车信息</small></h1>
        <ol class="breadcrumb">
          <li><a href="index.php"><i class="fa fa-dashboard"></i> 管理首页</a></li>
          <li><a href="/caravan"><i class="fa fa-dashboard"></i> 房车信息列表</a></li>
          <li class="active"><i class="fa fa-table"></i> 编辑房车信息</li>
        </ol>
        <div class="alert alert-success alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          请准确编辑房车信息
        </div>
      </div>
    </div>
    <!-- /.row -->
    <div class="row">
      <!-- 选项卡start -->
      <div class="bs-example">
        <!-- 选项卡标题start -->
        <ul class="nav nav-tabs" style="margin-bottom:15px;">
          <li class="active">
            <a href="#one" data-toggle="tab">基本信息</a>
          </li>
        </ul>
        <!-- 选项卡标题end -->
        <!-- 选项卡内容start -->
        <div id="myTabContent" class="tab-content">
          <!-- 选项卡内容1start -->
          <div id="one" class="tab-pane fade active in">
            <form id="form1" class="form-horizontal" role="form" action="/caravan" method="post">
              <!-- 基本信息start -->
              <div class="col-lg-6">
                <div class="panel panel-default">
                  <div class="panel-heading ">
                    <h3 class="panel-title">
                      基本信息
                    </h3>
                  </div>
                  <div class="panel-body">
                    <div class="form-group">
                      <label for="firstname" class="col-sm-3 control-label">房车名称</label>
                      <div class="col-sm-9">
                         <input type="text" class="form-control" name="name" id="firstname" value="" 
                            placeholder="请正确填写房车名称">
                      </div>
                    </div>
                    
                    <div class="form-group ">
                      <label for="firstname" class="control-label col-sm-3">车辆品牌</label>
                      <div class="col-sm-9">
                      <select class="form-control" name="brand_id">
                      {volist name='brand' id='vo'}
                      {if $cartpl_info.brand_id==$vo.id}
                        <option value={$vo.id} selected='true'>{$vo.name}</option>
                      {else} 
                        <option value={$vo.id} >{$vo.name}</option>
                      {/if}
                      {/volist}
                      </select>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="control-label col-sm-3">车型</label>
                      <div class="col-sm-9">
                      <select class="form-control" name="carcate_id">
                       {foreach $carcates as $k => $type}
                       {if $cartpl_info.carcate_id==$k}
                       <option value={$k} selected='true'>{$type}</option>
                       {else}
                       <option value={$k} >{$type}</option>
                       {/if}
                       {/foreach}
                      </select>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="control-label col-sm-3">等级</label>
                      <div class="col-sm-9">
                      <select class="form-control" name="grade">
                       {if $cartpl_info.grade == '1'}
                       <option selected='true' value="1">标准型</option>
                       <option value="2">豪华型</option>
                       <option value="3">尊贵型</option>
                       {elseif $cartpl_info.grade == '2'}
                       <option selected='true' value="2">豪华型</option>
                       <option value="1">标准型</option>
                       <option value="3">尊贵型</option>
                       {else}
                       <option selected='true' value="1">尊贵型</option>
                       <option value="1">标准型</option>
                       <option value="2">豪华型</option>
                       {/if}
                      </select>
                      </div>
                    </div>
                    <div class="form-group"  id="addressD">
                      <label for="firstname" class="control-label col-sm-3">房车服务机构</label>
                      <div class="col-sm-9">
                      <select name="addressCountry" class="addressCountry" data-first-title="选择国家" data-url="/caravan/getCountry"  style="width:100px;" ></select>
                      <select name="addressProvince" class="addressProvince" data-first-title="选择省" data-url="/caravan/getProvince" style="width:100px;"></select>
                      <select name="addressCity" id="addressCity" class="addressCity" data-first-title="选择城市"  data-url="/caravan/getCity" style="width:100px;"></select>
                      <select name="addressCamp" class="addressCamp" data-first-title="选择房车服务机构" data-url="/caravan/getCamp" data-required="true" style="width:100px;">
                      </select>
                      </div>
                    </div>

                    <div class="form-group">
                      <label for="firstname" class="col-sm-3 control-label"></label>
                      <div class="col-sm-9">
                      <input type="text" class="form-control" name="services_other" placeholder="填写其他房车服务机构的地址">
                      </div>
                    </div>

                    <div class="form-group">
                      <label for="firstname" class="col-sm-3 control-label">泊位编号</label>
                      <div class="col-sm-9">
                         <input type="text" class="form-control" name="park" id="firstname" value="{$cartpl_info.park}" 
                            placeholder="请填写泊位编号">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-3 control-label">注册日期</label>
                      <div class="col-sm-9">
                         <input type="text" class="form-control" name="register_date" id="firstname" value="{$cartpl_info.register_date}" 
                            placeholder="例，2014-10-12">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-3 control-label">车牌号</label>
                      <div class="col-sm-9">
                         <input type="text" class="form-control" name="plate_num" id="firstname" value="{$cartpl_info.plate_num}" 
                            placeholder="例，2014-10-12">
                      </div>
                    </div>

                    <div class="form-group">
                      <label for="firstname" class="control-label col-sm-3">国别</label>
                        <div class="col-sm-9">
                          <select class="form-control" name="carcountry_id">
                           {foreach $country as $k => $type}
                           {if $cartpl_info.carcountry_id =$k}
                           <option value={$k} selected='true'>{$type}</option>
                           {else}
                           <option value={$k} >{$type}</option>
                           {/if}
                           {/foreach}
                          </select>
                        </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="control-label col-sm-3">排挡</label>
                      <div class="col-sm-9">
                      <select class="form-control" name="gear">
                       {if $cartpl_info.gear == 1}
                       <option selected='true' value="1">自动挡</option>
                       <option value="3">无</option>
                       <option value="2">手动挡</option>
                       {elseif $cartpl_info.gear == 2}
                       <option selected='true' value="2">手动挡</option>
                       <option value="3">无</option>
                       <option value="1">自动挡</option>
                       {else}
                       <option selected='true' value="3">无</option>
                       <option value="1">自动挡</option>
                       <option value="2">手动挡</option>
                       {/if}
                      </select>
                      </div>
                    </div>
                    <div class="form-group ">
                      <label class="control-label col-sm-3">准驾类型</label>
                        <div class="col-sm-9">
                          <select class="form-control" name="drivetype_id">
                           {foreach $drive_type as $k => $v}
                           {if $cartpl_info.drivetype_id==$k}
                           <option value={$k} selected='true'>{$v}</option>
                           {else}
                           <option value={$k} >{$v}</option>
                           {/if}
                           {/foreach}
                          </select>
                        </div>
                    </div>



                  </div>
                </div>
              </div>
              <!-- 基本信息end -->
              <!-- 车内配套设施start -->
              <div class="col-lg-6">
                <div class="panel panel-default">
                  <div class="panel-heading">
                    <h3 class="panel-title">
                      车内配套设施
                    </h3>
                  </div>
                  <div class="panel-body">
                    <div class="form-group">
                      <label for="firstname" class="col-sm-4 control-label">长*宽*高(mm)</label>
                      <div class="col-sm-8">
                         <input type="text" class="form-control" name="size" id="firstname" value="{$cartpl_info.size}" 
                            placeholder="例，5999*2420*3034">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-4 control-label">单人床数量(张)</label>
                      <div class="col-sm-2">
                         <input type="text" class="form-control" name="single_bed_num" id="firstname" value="{$cartpl_info.single_bed_num}" 
                            placeholder="8"></input>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-4 control-label">双人床数量(张)</label>
                      <div class="col-sm-2">
                         <input type="text" class="form-control" name="double_bed_num" id="firstname" value="{$cartpl_info.double_bed_num}" 
                            placeholder="8"></input>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-4 control-label">可住几人</label>
                      <div class="col-sm-8">
                         <input type="text" class="form-control"  name="people_num" id="firstname" value="{$cartpl_info.people_num}" 
                            placeholder="请直接填写阿拉伯数字"></input>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-4 control-label">沙发乘坐人数</label>
                      <div class="col-sm-8">
                         <input type="text" class="form-control"  name="sofe_num" id="firstname" value="{$cartpl_info.sofe_num}" 
                            placeholder="请直接填写阿拉伯数字"></input>
                      </div>
                    </div>
                    

                    {foreach $ziduans as $key=>$value}
                    <div class="form-group ">
                      <label for="firstname" class="control-label col-sm-4">{$key|lang}</label>
                      {foreach $value as $k=>$v}
                      <label class="radio-inline">
                      {if $cartpl_info->$key==$k}
                      <input id="{$key.$k}" name="{$key}" checked="true" value="{$k}"  type="radio">{$v|lang}
                      {else}
                      <input id="{$key.$k}" name="{$key}" value="{$k}"  type="radio">{$v|lang}
                      {/if}
                      </label>
                      {/foreach}
                     </div>
                  {/foreach}

                  </div>
                </div>
              </div>
              <!-- 车内配套设施end -->
              <div class="col-lg-10 col-lg-offset-1">
                <div class="panel panel-default">
                  <div class="panel-heading">
                    <h3 class="panel-title">
                      选择房车封面图片
                    </h3>
                  </div>
                  <div class="panel-body">

                    <!--封面图片-->
                    <div class="caravan-info-form">
                      <h3>封面图片（请按规范上传1张 图片大小2MB）</h3><br>
                      <div style="margin:5px auto;width:875px; min-height:200px;">
                        <div id="caravancover">
                            <!--用来存放item-->
                            <div id="fileList" class="uploader-list"></div>
                            <div id="filePicker">选择图片</div>
                        </div>
                        {if !empty($list.caravancover)}
                        <img src="{$list.caravancover['0']}" width="800px">
                        {/if}
                      </div>
                    </div>
                    <!--内容图片-->
                    <div class="caravan-info-form">
                      <h3>内容图片(请上传5张，包括房车内、外图片和内饰图片 单张图片大小2MB)</h3>
                      <div style="margin:5px auto;width:875px; min-height:200px;">
                        <div id="caravanphoto" ></div>
                        {if !empty($list.piccaravan['0'])}
                        <img src="{$list.piccaravan['0']}" width="400px">
                        {/if}
                        {if !empty($list.piccaravan['1'])}
                        <img src="{$list.piccaravan['1']}" width="400px">
                        {/if}
                        {if !empty($list.piccaravan['2'])}
                        <img src="{$list.piccaravan['2']}" width="400px">
                        {/if}
                        {if !empty($list.piccaravan['3'])}
                        <img src="{$list.piccaravan['3']}" width="400px">
                        {/if}
                        {if !empty($list.piccaravan['4'])}
                        <img src="{$list.piccaravan['4']}" width="400px">
                        {/if}
                      </div>
                    </div>

                  </div>
                </div>
              </div>
              <div class="col-lg-6 col-lg-offset-6">
                <input type="button" value="返回" class="btn btn-default"  onclick="javascript:history.back(-1);" />
                <button class="btn btn-primary" type="submit">提交</button>
              </div>
            </form>
          </div>
          <!-- 选项卡内容1end -->
        </div>
        <!-- 选项卡内容end -->
      </div>
      <!-- 选项卡end -->
    </div>

  </div><!-- /#page-wrapper -->

<script src="/front/js/jquery.js"></script>
<!-- 世界城市地区联动 -->
<script src="/js/jquery.cxselect.js"></script>
<script>
  $('#addressD').cxSelect({
  selects: ['addressCountry','addressProvince', 'addressCity','addressCamp'],
  jsonName: 'area_name',
  jsonValue: 'area_code'  }, function(api) {
    cxSelectApi = api;
  });
</script>
<script type="text/javascript" src="/front/diyUpload/js/webuploader.js"></script>
<script type="text/javascript" src="/front/diyUpload/js/diyUpload.js"></script>
<script src="/front/js/weifeng.js" type="text/javascript"></script>
<script type="text/javascript">
  $(function(){
    /*
    * 服务器地址,成功返回,失败返回参数格式依照jquery.ajax习惯;
    * 其他参数同WebUploader
    */
    $('#caravancover').diyUpload1({
      url:'/caravan/postUploadImg',
      success:function( data ) {
        $('#form1').append('<input type="hidden" name="caravancover[]" value="'+data.url+'" />'); 
      },
      error:function( err ) {
        // console.info( err ); 
      },
      buttonText : '选择房车封面',
      fileNumLimit:1,
      fileSingleSizeLimit:2*1024 * 1024,
      thumb:{
        width: 800,
          height: 200,
      }
    });
    $('#caravanphoto').diyUpload({
      url:'/caravan/postUploadImg',
      success:function( data ) {
        $('#form1').append('<input type="hidden" name="caravanphoto[]" value="'+data.url+'" />'); 
      },
      error:function( err ) {
        console.info( err );  
      },
      buttonText : '选择5张房车图片',
      chunked:true,
      // 分片大小
      chunkSize:512 * 1024,
      //最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
      fileNumLimit:5,
      fileSizeLimit:10*1024 * 1024,
      fileSingleSizeLimit:2*1024 * 1024,
      accept: {},
      thumb:{
        width: 388,
          height: 200,
      }
    });
  }); 
</script>